import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt


"""
    sns context 设置绘图面积的大小
"""


def color_customer():
    """
        多种颜色的自定义 hls 自动颜色
    :return:
    """
    # 使用另外图风格  得到多种颜色
    with sns.axes_style("dark"):
        color = sns.color_palette()
        sns.palplot(color)
        sns.palplot(sns.color_palette("hls", n_colors=12))


if __name__ == '__main__':

    figure = plt.figure()
    with sns.axes_style("whitegrid"):

        # {paper, notebook, talk, poster}
        sns.set_context("paper")
        axes = figure.add_subplot(1, 2, 1)
        x = np.linspace(-10, 10, 100)
        axes.scatter(x, 1 / x)

    with sns.axes_style("darkgrid"):
        """
            设置多条曲线，并标注内容
        """


        axes2 = figure.add_subplot(1, 2, 2)
        x1 = np.linspace(-10, 10, 100)
        y1 = np.sin(x1)
        x2 = x1 - 4

        # 分别画出多条曲线
        axes2.plot([1, 2, 3], [1, 2, 3], 'go-', label='line 1', linewidth=2)
        axes2.plot([1, 2, 3], [1, 4, 9], 'rs',  label='line 2')
        # axes2.legend(loc = 'upper right')

        # 一次画出多条曲线
        axes2.plot(x1, y1, x2, y1, label=['line 3', 'line 4'], antialiased=False)
        axes2.legend(loc='upper right')


        # sns.kdeplot(x,y1,cmap_d =sns.color_palette("Blues_d"))


    plt.show()